import request from "@/utils/request.ts";
import {
  DoctorResult,
  HospitalDepartmentReservationResult,
  LoginData,
  Result,
  VisitingUserResult,
  WorkingListResult,
} from "@/types/types.ts";

enum Api {
  // 获取医院列表
  HOSPITAL_DETAIL = "/hosp/hospital/",
  // 获取医院科室
  HOSPITAL_DEPARTMENT = "/hosp/hospital/department/",
  // 获取短信验证码
  SEND_CODE = "/sms/send/",
  // 登录
  LOGIN = "/user/login",
  // 获取某个医院科室挂号信息
  SCHEDULE_RULE = "/hosp/hospital/auth/getBookingScheduleRule/",
  // 排班列表
  WORKING_LIST = "/hosp/hospital/auth/findScheduleList/",
  // 就诊人信息
  VISITING_USER = "/user/patient/auth/findAll",
  // 获取挂号医生信息
  DOCTOR_INFO = "/hosp/hospital/getSchedule/",
}

// 获取医院详情信息
export const doGetHospitalDetail = (hospcode: string) => {
  return request<Result, any>({
    url: Api.HOSPITAL_DETAIL + hospcode,
    method: "get",
  }).then((res) => {
    return res;
  });
};
// 获取医院科室信息
export const doGetHospitalDepartments = (hospcode: string) => {
  return request<Result, any>({
    url: Api.HOSPITAL_DEPARTMENT + hospcode,
    method: "get",
  }).then((res) => {
    return res;
  });
};
// 获取短信验证码
export const doSendCode = (mobile: string) => {
  return request<Result, any>({
    url: Api.SEND_CODE + mobile,
    method: "get",
  }).then((res) => {
    return res;
  });
};

// 登录
export const doLogin = (data: LoginData) => {
  return request<Result, any>({
    url: Api.LOGIN,
    method: "post",
    data,
  }).then((res) => {
    return res;
  });
};
// 获取某个医院科室挂号信息
export const doGetScheduleRule = (
  page: number,
  limit: number,
  hospcode: string,
  deptcode: string,
) => {
  return request<HospitalDepartmentReservationResult>({
    url:
      Api.SCHEDULE_RULE + page + "/" + limit + "/" + hospcode + "/" + deptcode,
    method: "get",
  }).then((res) => {
    return res;
  });
};

// 获取某天排版数据
export const doGetWorkingList = (
  hospcode: string,
  deptcode: string,
  workDate: string,
) => {
  return request<WorkingListResult>({
    url: Api.WORKING_LIST + hospcode + "/" + deptcode + "/" + workDate,
    method: "get",
  }).then((res) => {
    return res;
  });
};
// 获取某一个账号下就诊人信息
export const doGetVisitingUser = () => {
  return request<VisitingUserResult>({
    url: Api.VISITING_USER,
    method: "get",
  }).then((res) => {
    return res;
  });
};
// 获取挂号医生信息
export const doGetSchduleDoctorInfo = (schduleId: string) => {
  return request<DoctorResult>({
    url: Api.DOCTOR_INFO + schduleId,
    method: "get",
  }).then((res) => {
    return res;
  });
};
